package com.minstone.api.unit.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.minstone.api.unit.service.IUnitInfoService;
import com.minstone.common.bean.ResultBean;
import com.minstone.common.util.MapUtils;
import com.minstone.common.util.WebUtil;

@Controller
@RequestMapping(value = "/api/unit")
public class UnitInfoAction {

	@Autowired
	private IUnitInfoService unitInfoService;

	/**
	 * 服务信息表存在该url的情况
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/unitList/query.v")
	@ResponseBody
	public ResultBean queryUnitList1(HttpServletRequest request) {

		Map param = WebUtil.getParamMap(request);

		// 当前页
		int pageIndex = MapUtils.getInt(param, "pageIndex", 1);
		// 每页显示记录数
		int pageRowNum = MapUtils.getInt(param, "pageRowNum", 10);

		Map pageMap = this.unitInfoService.selectUnitInfo(param, pageIndex, pageRowNum);

		return ResultBean.ok(pageMap);
	}

	@RequestMapping(value = "/unitList2/query.v")
	@ResponseBody
	public ResultBean queryUnitList2(HttpServletRequest request) {

		Map param = WebUtil.getParamMap(request);

		// 当前页
		int pageIndex = MapUtils.getInt(param, "pageIndex", 1);
		// 每页显示记录数
		int pageRowNum = MapUtils.getInt(param, "pageRowNum", 10);

		Map pageMap = this.unitInfoService.selectUnitInfo(param, pageIndex, pageRowNum);

		return ResultBean.ok(pageMap);
	}

	/**
	 * 服务信息表不存在该url 使校验不生效的情况.
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/unitList1/query.v")
	@ResponseBody
	public ResultBean queryUnitList3(HttpServletRequest request) {

		Map param = WebUtil.getParamMap(request);

		// 当前页
		int pageIndex = MapUtils.getInt(param, "pageIndex", 1);
		// 每页显示记录数
		int pageRowNum = MapUtils.getInt(param, "pageRowNum", 10);

		Map pageMap = this.unitInfoService.selectUnitInfo(param, pageIndex, pageRowNum);

		return ResultBean.ok(pageMap);
	}

}
